package controller.res;

import model.MResourceType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import common.interf.IErrorHandle;

import service.interf.IResource;

@Controller
@RequestMapping("/res")
public class ResourceTypeEditController {
	@Autowired
	private IResource res;
	private IErrorHandle errorHandle;
	
	public void setErrorHandle(IErrorHandle errorHandle) {
		this.errorHandle = errorHandle;
	}
	@RequestMapping("/add_resourceType.htm")
	@ResponseBody
	public String add(MResourceType model){
		String x;
		try{
			x = res.addResourceType(model);
		}catch(Exception e){
			x = errorHandle.handleErr(e);
		}
		return x;
	}
	@RequestMapping("/edit_resourceType.htm")
	@ResponseBody
	public String edit(MResourceType model){
		String x;
		try{
			x = res.editResourceType(model);
		}catch(Exception e){
			x = errorHandle.handleErr(e);
		}
		return x;
	}
	@RequestMapping("/del_resourceType.htm")
	@ResponseBody
	public String del(MResourceType model){
		String x;
		try{
			x = res.delResourceType(model);
		}catch(Exception e){
			x = errorHandle.handleErr(e);
		}
		return x;
	}
	
	/**
	 * 批量保存
	 */
	@RequestMapping("/batch_saveResourceType.htm")
	@ResponseBody
	public String batch(MResourceType model){
		String x="";
		try{
			x = res.batchUpdateType(model.getDatas());
		}catch(Exception e){
			x = errorHandle.handleErr(e);
		}
		return x;
	}
	
}
